Uec3.PartnerAddressAddWindow = Ext.extend(Ext.app.Module,{
      id:'partnerAddress_add',
      type:'common/partnerAddressAdd',
      
      getPanel : function(param){                	       	
      	    var areaId_hidden = new Ext.form.Hidden({
			     name:'areaId'
			});
			// 区县下拉框
		    var district_comboBox = getDistrictCombox(Uec3.App.Constants.homeUrl, areaId_hidden);// dist_cmb.setWidth(80);
		    district_comboBox.hiddenName = null;
		    district_comboBox.name = 'district';
		    // 城市下拉框
		    var city_comboBox = getCityCombox(Uec3.App.Constants.homeUrl, district_comboBox, areaId_hidden);
		    city_comboBox.hiddenName = null;
		    city_comboBox.name = 'city';
		    // 省份下拉框
		    var province_comboBox = getProvinceCombox(Uec3.App.Constants.homeUrl,city_comboBox, district_comboBox, areaId_hidden);
		    province_comboBox.hiddenName = null;
		    province_comboBox.name = 'province';
			
			var partnerAddress_form = new Ext.form.FormPanel({
				labelAlign : 'right',
				labelWidth : 60,				
				frame : true,
				width : 600,
				autoHeight : true,
				items : [
				   {
					layout : 'column',
					items : [
					  {
						columnWidth : .4,
						layout : 'form',
						defaultType : 'textfield',
						items:[
						   {
						   	 xtype:'hidden',
						     name:'partnerId'
						   },						      
						     areaId_hidden,
							 province_comboBox,
							 city_comboBox,
							 district_comboBox, 
						   {
							  name : 'street',
							  fieldLabel : '通讯地址',
							  xtype : 'textfield',
							  autoScroll:true
							}]
					   },{
						  columnWidth : .5,
						  layout : 'form',
						  defaultType : 'textfield',
						  items : [
						        {
									name : 'postCode',
									fieldLabel : '邮编',
									xtype : 'numberfield'
								}, {
									name : 'receiverName',
									fieldLabel : '联系人'
								}, {
									name : 'phone',
									fieldLabel : '电话',
									xtype : 'numberfield'
								}, {
									name : 'mobile',
									fieldLabel : '手机',
									xtype : 'numberfield',
									maxLength : '11',
									minLength : '11'
								}]
					}]
				}],
				buttons : [{
					text : '保存',
					handler : function() {
						if (!partnerAddress_form.getForm().isValid()) {
							Ext.Msg.alert("提示", "表单校验未通过");
							return;
						}
						var formValues = partnerAddress_form.getForm().getValues();
						var jsonAll = Ext.encode(formValues);
						Ext.Ajax.request({
							url : Uec3.App.Constants.homeUrl+ '/partnerAddress/partnerAddress!save.do',
							params : {
								queryParam : jsonAll
							},
							success : function(response,options) {
								var resp =Ext.decode(response.responseText);
								Ext.MessageBox.alert("提示",resp.msg);
								var address = '地址:' + (resp.main.province ? resp.main.province : '') + (resp.main.city ? resp.main.city : '') + 
									(resp.main.district ? resp.main.district : '') + (resp.main.street ? resp.main.street : '') + 
									(resp.main.receiverName ? ';联系人:' + resp.main.receiverName : '') + 
									(resp.main.phone ? ';电话:' + resp.main.phone : '') + 
									(resp.main.mobile ? ';手机:' + resp.main.mobile : '');
								resp.main.address = address;
								param.desktopModule.setLookupValue(resp.main,partnerAddress_form.ownerCt);
							    var lookup=partnerAddress_form.ownerCt.lookup;				      
				                if(lookup.lookupCallBackEvents){
				       	             Ext.each(lookup.lookupCallBackEvents,function(event){
				       		             if(event == 'lookupChange'){
				       			              lookup.fireEvent(event,resp.main);
				       		             }else{
				       			              lookup.fireEvent(event);
				       		             }
				       	             });
				                }
								partnerAddress_form.ownerCt.close();
							},
							failure : function(response,options) {
								Ext.Msg.alert('失败', '保存客户地址出错!');
							}
							
						});
					}
					
				}, {
					text : '取消',
					handler : function() {
						partnerAddress_form.ownerCt.destroy();
					}
				}],				
				buttonAlign : 'center'
			});		
			
			init();
			
			function init(){
		       	partnerAddress_form.getForm().findField("partnerId").setValue(param.partnerId ? param.partnerId : param.partnerCmb.getValue());		       		
			   		    
			}
			
           return partnerAddress_form;
      },
      
      createWindow:function(param){
      	
      	  var partnerId = param.partnerId ? param.partnerId : param.partnerCmb.getValue();
	      if( !partnerId){
	      	 Ext.MessageBox.alert('提示','请选择采购单位');
	      	 return;
	      }
      	
          var desktop = this.app.getDesktop();
    	  var win = desktop.getWindow("partnerAddress_add");
    	  if(!win){    		
    	  	win = desktop.createWindow({
            id: "partnerAddress_add",   
            modal : true,
            title: '客户地址增加',
            width : 500,
			autoHeight : true,
			iconCls : 'acc-icon',
			shim : false,
			animCollapse : false,
			constrainHeader : true,
			maximizable : false,
			minimizable : false,
			resizable : false,                             
            items:[this.getPanel(param)]        
         });        
       }
       win.show();
      /* win.on("show",function(){
          var view_panel = this.getPanel(param);    
	      win.add(view_panel);
          win.doLayout();               
       },this);*/
             
      }
}); 